<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>API Data Fetcher</title>
</head>
<body>
    <script>//html5+js循环爬取1000次网络api的json输出值，并保存json到文件
        async function fetchData() {
            let allData = [];
            for (let i = 0; i < 1000; i++) {
                try {
                    const response = await fetch('https://xjj.7xnn.cn/fetch_videos.php?category=suiji&count=10');
                    const data = await response.json();
                    allData.push(data);
                } catch (error) {
                    console.error('Error fetching data:', error);
                }
            }
            saveDataAsFile(allData);
        }

        function saveDataAsFile(data) {
            const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = 'data.json';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(url);
        }

        fetchData();
    </script>
</body>
</html>